import 'reflect-metadata';

function LoadComponent(...name: string[]): ClassDecorator {
  return target => {
    Reflect.defineMetadata('name', name, target);
  };
}

function Definition(defs: Array<any>) {
  return defs.reduce((initial, def) => {
    let names: Array<string> = Reflect.getMetadata('name', def);
    names = names instanceof Array ? names : [names];
    names.forEach(name => initial[name] = def);
    return initial;
  }, {});
}

export {LoadComponent, Definition}
